﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports KadGen.MetadataExtraction
Imports KadGen.MetadataAdapter

Public Class ExtractMetadata
   Public Shared Function Extract(ByVal serverName As String, _
                      ByVal databaseName As String) _
                      As IO.Stream
      Dim loadMetadata = LoadMetadataProvider.GetLoadMetadata(Nothing, serverName, databaseName)
      Dim metadataWrapper = loadMetadata.Load(False, String.Empty, String.Empty, String.Empty, CodeGenerationSupport.TargetLanguage.VB, _
                                             False, String.Empty, True, True, CodeGenerationSupport.KeywordTreatment.LeadingUnderscore, _
                                             CodeGenerationSupport.BlankTreatment.ReplaceWithUnderscore, _
                                             False, String.Empty, False, True, True, CodeGenerationSupport.KeywordTreatment.LeadingUnderscore, _
                                             CodeGenerationSupport.BlankTreatment.ReplaceWithUnderscore, _
                                             CodeGenerationSupport.ViewIDType.Prefix, String.Empty, String.Empty, String.Empty, False)
      Dim stream As New IO.MemoryStream
      Dbs.OutputWrapper(stream, metadataWrapper)
      Return stream
   End Function

End Class

'Public Interface ILoadMetadata
'   Function Load( _
'                  ByVal skipStoredProcs As Boolean, _
'                  ByVal selectPatterns As String, _
'                  ByVal setSelectPatterns As String, _
'                  ByVal lookupPrefix As String, _
'                  ByVal targetLanguage As CodeGenerationSupport.TargetLanguage, _
'                  ByVal removeAllPrefixes As Boolean, _
'                  ByVal prefixes As String, _
'                  ByVal friendlyCaps As Boolean, _
'                  ByVal removeUnderscores As Boolean, _
'                  ByVal keywordTreatment As CodeGenerationSupport.KeywordTreatment, _
'                  ByVal blankTreatment As CodeGenerationSupport.BlankTreatment, _
'                  ByVal columnRemoveAllPrefixes As Boolean, _
'                  ByVal columnPrefixes As String, _
'                  ByVal columnRemoveTablePrefix As Boolean, _
'                  ByVal columnFriendlyCaps As Boolean, _
'                  ByVal columnRemoveUnderscores As Boolean, _
'                  ByVal columnKeywordTreatment As CodeGenerationSupport.KeywordTreatment, _
'                  ByVal columnBlankTreatment As CodeGenerationSupport.BlankTreatment, _
'                  ByVal viewIDType As CodeGenerationSupport.ViewIDType, _
'                  ByVal viewIDText As String, _
'                  ByVal customAttributeNamespace As String, _
'                  ByVal createMetadata As String, _
'                  ByVal skipExtendedProperties As Boolean) _
'                  As MetadataWrapper.DbsMetaDataRoot
'End Interface
